import fetch from 'common/src/utils/fetch';
import cryp from  'common/src/utils/secret';
// 学籍
export function findStuInfoList(data) {
    return fetch({
        url: '/api/studentservice/studentInfo/findStuInfoList',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}
/**
 * 使用pageCondition的分页查询url
 */
export const findStuInfoPageUrl =
    '/api/studentservice/studentInfo/findStuInfoPage';
/**
 * 导出学生基本信息列表
 * @param {Object} params
 */
export function findStuInfoListExport(params) {
    let url = '/api/studentservice/studentInfo/findStuInfoListExport';
    let remove_params = ['pageNum_', 'pageSize_'];
    let queryParam = '';
    for (let key in params) {
        // 去掉分页
        if (remove_params.includes(key)) {
            continue;
        }
        // 去掉空参数
        if (params[key] == '') {
            continue;
        }
        queryParam += `${key}=${params[key]}&`;
    }
    window.open(`${url}?${queryParam}`);
}

/**
 * 查询学生可见信息
 * @param data
 */
export function getStudentInfo(data) {
    return fetch({
        url: '/api/studentservice/studentInfo/findViewColumnByTable',
        method: 'post',
        data
    });
}

/**
 * 学籍字典查询接口
 */
export function getFieldsByTableName(query) {
    return fetch({
        url: '/api/studentservice/studentDic/getByTableName?' + query,
        method: 'get'
    });
}

/**
 * 查询学籍配置列表, 可见 可写列表
 */
export function getOperatesOfField() {
    return fetch({
        url: '/api/studentservice/configOptions/getConOptList',
        method: 'get'
    });
}

/**
 * 保存各字段的配置（可见可改等配置）
 */
export function saveOperatesOfField(data) {
    return fetch({
        url: '/api/studentservice/configOptions/saveConfigInfo',
        method: 'post',
        data
    });
}

/**
 * 根据表名查询配置信息（可见可改等配置）
 */
export function getConfigInfo(query) {
    return fetch({
        url: '/api/studentservice/configOptions/getConfigInfo?' + query,
        method: 'get'
    });
}

/**
 * 查询可编辑字段
 * @param data
 */
export function getEidtColumn(data) {
    return fetch({
        url: '/api/studentservice/studentInfo/findEidtColumn',
        method: 'post',
        data
    });
}

export function getAllColumn(options) {
    let allColumn = getStudentInfo(options);
    let editColumn = getEidtColumn(options);
    let getAllColumn = new Promise((resolve, reject) => {
        Promise.all([allColumn, editColumn]).then(res => {
            resolve(res);
        });
    });
    return getAllColumn;
}

/**
 * 单表保存可编辑值
 * @param data
 */
export function saveEdit(data) {
    return fetch({
        url: '/api/studentservice/studentInfo/saveEditColumnVal',
        method: 'post',
        data
    });
}

/**
 * 查询院审或者校审可编辑字段以及值
 * @param params
 */
export function getEidtAcaEduColumn(params) {
    return fetch({
        url: '/api/studentservice/studentInfo/findEidtAcaEduColumn/',
        method: 'get',
        params: params
    });
}

/**
 * 保存院审或者校审所有值
 * @param data
 */
export function saveEditAcaEduColumnVal(data) {
    return fetch({
        url: '/api/studentservice/studentInfo/checkEditAcaEduColumnVal',
        method: 'post',
        data
    });
}

/**
 * 查询教师列表
 * @param {data} data
 */
export function findTeacherInfoList(data) {
    return fetch({
        url: '/api/studentservice/teacherInfo/findTeacherInfoList',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}
export function findTeacherSelectList(data) {
    return fetch({
        url: '/api/studentservice/teacherInfo/findSelectList',
        method: 'post',
        headers: { 'Content-Type': 'application/json' },
        data
    });
}
/**
 * 查询教育背景列表
 * @param studentId
 */
export function getEduBackgroudList(studentId) {
    return fetch({
        url: '/api/studentservice/studentEduBackg/findEduBackgroudList',
        method: 'get',
        params: {
            studentId: studentId
        }
    });
}

/**
 * 查询单个教育背景
 * @param ideee
 */
export function getEduBackgroud(id) {
    return fetch({
        url: '/api/studentservice/studentEduBackg/findEduBackgroud',
        method: 'get',
        params: {
            id: id
        }
    });
}

/**
 * 新增教育背景
 * @param data
 */
export function addEduBackgroud(data) {
    return fetch({
        url: '/api/studentservice/studentEduBackg/addEduBackgroud',
        method: 'post',
        data
    });
}

/**
 * 修改教育背景
 * @param data
 */
export function updateEduBackgroud(data) {
    return fetch({
        url: '/api/studentservice/studentEduBackg/updateEduBackgroud',
        method: 'post',
        data
    });
}

/**
 * 删除教育背景
 * @param id
 */
export function deleteEduBackgroud(id) {
    return fetch({
        url: '/api/studentservice/studentEduBackg/deleteEduBackgroud',
        method: 'delete',
        params: {
            id: id
        }
    });
}

/**
 * 获取所有异动设置
 * @param data
 */
export function getAbnormalList(data) {
    return fetch({
        url: '/api/studentservice/abnormal/template',
        method: 'post',
        data
    });
}

/**
 * 学籍异动申请
 * @param data
 */
export function abnormalApply(data) {
    return fetch({
        url: '/api/studentservice/abnormal/apply',
        method: 'post',
        data
    });
}

/**
 * 学籍异动申请
 * @param data
 */
export function abnormalUpdate(data) {
    return fetch({
        url: '/api/studentservice/abnormal/template',
        method: 'put',
        data
    });
}
/**
 * 下载学生权限字段模板
 */
export function downloadTemplate() {
    return '/api/studentservice/configOptions/downloadTemplate';
}
/**
 * 学生详情查询
 */
export function getStudentDetail(data) {
    if(data.studentId) {
        data.studentId = cryp.encrypt(data.studentId)
    }
    return fetch({
        url: '/api/studentservice/studentDetailInfo/stuDetailByClass',
        method: 'post',
        data
    });
}
/**
 * 学生详情提交
 */
export function stuDetailSubmit(data) {
    return fetch({
        url: '/api/studentservice/studentDetailInfo/stuDetailSubmit',
        method: 'post',
        data
    });
}
/**
 * 字段院审、校审配置角色查询
 */
export function getApproRoles(data) {
    return fetch({
        url: '/api/studentservice/configOptions/getApproRoles',
        method: 'post',
        data
    });
}
/**
 * 字段配置角色下人员
 */
export function getApproUser(roleId, type, configId) {
    return fetch({
        url:
            '/api/studentservice/configOptions/getApproUser?roleId=' +
            roleId +
            '&type=' +
            type +
            '&configId=' +
            configId,
        method: 'get'
    });
}
/**
 * 角色人员的配置字段信息
 */
export function getApproFields(data) {
    return fetch({
        url: '/api/studentservice/configOptions/getApproFields',
        method: 'post',
        data
    });
}
/**
 * 角色人员的配置字段信息
 */
export function addFieldRoleConfig(data) {
    return fetch({
        url: '/api/studentservice/configOptions/addFieldRoleConfig',
        method: 'post',
        data
    });
}
/**
 * 学生指定导师列表
 */
export function getAppointList(data) {
    return fetch({
        url: '/api/studentservice/stuAppoint/getAppointList',
        method: 'post',
        data
    });
}
/**
 * 无导师学生列表
 */
export function getNoAppointStuList(data) {
    return fetch({
        url: '/api/studentservice/stuAppoint/getNoAppointStuList',
        method: 'post',
        data
    });
}
/**
 * 选中无导师学生
 */
export function selectedStu(data) {
    return fetch({
        url: '/api/studentservice/stuAppoint/selectedStu',
        method: 'post',
        data
    });
}
/**
 * 导师列表
 */
export function getAppointTeaList(data) {
    return fetch({
        url: '/api/studentservice/stuAppoint/getAppointTeaList',
        method: 'post',
        data
    });
}
/**
 * 指定导师
 */
export function appointTea(data) {
    return fetch({
        url: '/api/studentservice/stuAppoint/appointTea',
        method: 'post',
        data
    });
}
/**
 * 删除学生名单
 */
export function deleteStuAppointed(id) {
    return fetch({
        url: '/api/studentservice/stuAppoint/deleteStuAppointed?id=' + id
    });
}
/**
 * 下载导入模板
 */
export function downloadStuTemplate() {
    return '/api/studentservice/stuAppoint/downloadTemplate';
}
/**
 * 导出学生名单
 */
export function exportAppointList(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/stuAppoint/exportAppointList?' + params;
}

/**
 * 新增信息激活设置
 */
export function addConfig(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/addConfig',
        method: 'post',
        data
    });
}
/**
 * 查询信息激活设置
 */
export function configList(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/configList',
        method: 'post',
        data
    });
}
/**
 * 获取单个信息激活设置
 */
export function getConfig(configId) {
    return fetch({
        url: '/api/studentservice/stuActivation/getConfig?configId=' + configId
    });
}
/**
 *  修改信息激活设置
 */
export function updateConfig(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/updateConfig',
        method: 'post',
        data
    });
}
/**
 * 删除信息激活设置
 */
export function deleteConfig(configId) {
    return fetch({
        url:
            '/api/studentservice/stuActivation/deleteConfig?configId=' +
            configId,
        method: 'get'
    });
}
/**
 * 获取字段类型
 */
export function fieldType() {
    return fetch({
        url: '/api/studentservice/stuActivation/fieldType'
    });
}
/**
 * 获取字段类型下的所有字段信息
 */
export function fieldsByfieldType(fieldClasses) {
    return fetch({
        url:
            '/api/studentservice/stuActivation/fieldsByfieldType?fieldClasses=' +
            fieldClasses
    });
}
/**
 *  字段设置
 */
export function fieldConfig(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/fieldConfig',
        method: 'post',
        data
    });
}
/**
 *  查询单个配置中的字段信息
 */
export function singleConfig(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/singleConfig',
        method: 'post',
        data
    });
}

/**
 *  学生激活配置信息列表
 */
export function activationList(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/activationList',
        method: 'post',
        data
    });
}
/**
 * 导出学生激活列表
 */
export function exportactivationList(query) {
    let params = '';
    for (let key in query) {
        if (
            query[key] &&
            key !== 'pageSize_' &&
            key !== 'pageNum_' &&
            query[key].length !== 0
        ) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/stuActivation/exportactivationList?' + params;
}
/**
 *  院审/校审字段审批
 */
export function colSchSubmit(data) {
    return fetch({
        url: '/api/studentservice/studentDetailInfo/colSchSubmit',
        method: 'post',
        data
    });
}

/**
 *  学生登录后弹出窗口信息
 */
export function checkActivation(studentId) {
    return fetch({
        url:
            '/api/studentservice/stuActivation/checkActivation?studentId=' +
            studentId
    });
}
/**
 *  学生确认完成信息后激活
 */
export function activation(data) {
    return fetch({
        url: '/api/studentservice/stuActivation/activation',
        method: 'post',
        data
    });
}

/**
 *  信息变更日志列表
 */
export function getLogList(data) {
    return fetch({
        url: '/api/studentservice/fieldLog/getLogList',
        method: 'post',
        data
    });
}

/**
 *  信息变更日志列表导出
 */
export function exportLogList(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/fieldLog/exportLogList?' + params;
}

/**
 * 查询学生下拉组件的接口
 * @param {*} data
 */
export function findStuInfoListForSelect(data) {
  return fetch({
      url: '/api/studentservice/studentInfo/findStuInfoListForSelect',
      method: 'post',
      headers: { 'Content-Type': 'application/json' },
      data
  });
}


//本研互选（本科生学生名单）
export function bkStudentElectionInfo(data){
    return fetch({
     url:'/api/electionservice/elcMutualCross/getElcMutualCrossList',
     data,
     method:'post'
    })
}

